package com.learn.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component
@Aspect
@Slf4j
public class MyAspect2 {
    @Pointcut("execution(* com..DeptServiceImpl.*(..))")
    public void pt(){}

    @Around("pt()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        //获取类名
        String name = joinPoint.getTarget().getClass().getName();
        log.info("调用的类名{}",name);

        //获取方法名
        String name1 = joinPoint.getSignature().getName();
        log.info("调用的方法名{}",name1);

        //获取参数
        Object[] args = joinPoint.getArgs();
        log.info("参数{}", Arrays.toString(args));

        //调用方法获取返回值
        return joinPoint.proceed();
    }
}
